Allow using a pre-authenticated google access token - #231
Open
kesor wants to merge 1 commit into
Open
Conversation
kesor
force-pushed
the
feat/pre-auth-goog-tokens
branch
from
June 2, 2026 10:31
c8dfe11 to
a6dc16b
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an alternative authentication path in the Google Admin API client that loads an OAuth2 access token from a file specified by the SSOSYNC_ACCESS_TOKEN_FILE environment variable, bypassing the standard service account JWT flow.
Changes:
- Introduces env-var-driven token file loading for Google Admin client construction.
- Constructs an
oauth2.StaticTokenSourcefrom the file contents and uses it to build the admin service. - Falls back to the existing service account JWT flow when the env var is unset.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+53
to
+54
| // Allow injecting access token via env var pointing to a file with { "access_token": "...", "expiry": "..." } | ||
| if tokenPath := os.Getenv("SSOSYNC_ACCESS_TOKEN_FILE"); tokenPath != "" { |
Comment on lines
+66
to
+71
| expiry := time.Now().Add(time.Hour) | ||
| if tokenData.Expiry != "" { | ||
| if parsedExpiry, err := time.Parse(time.RFC3339, tokenData.Expiry); err == nil { | ||
| expiry = parsedExpiry | ||
| } | ||
| } |
Comment on lines
+72
to
+77
| tok := &oauth2.Token{ | ||
| AccessToken: tokenData.AccessToken, | ||
| TokenType: "Bearer", | ||
| Expiry: expiry, | ||
| } | ||
| ts := oauth2.StaticTokenSource(tok) |
Comment on lines
+53
to
+54
| // Allow injecting access token via env var pointing to a file with { "access_token": "...", "expiry": "..." } | ||
| if tokenPath := os.Getenv("SSOSYNC_ACCESS_TOKEN_FILE"); tokenPath != "" { |
kesor
force-pushed
the
feat/pre-auth-goog-tokens
branch
from
June 2, 2026 13:16
a6dc16b to
ba656ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
Enable using a custom Google client that reuses a pre-authenticated Access Token, thus skipping the complexity of trying to use
ssosyncwith WIF and other methods of authentication and allows to do all of that externally.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.